function soso(){
	var content = document.getElementById('content').value;
	alert('搜索的内容是：' + content)
}

/* 时间脚本 */
function showTime(){
	var date = new Date();
	var y = date.getFullYear()
	var m = date.getMonth() + 1;
	var d = date.getDate();
	var h = date.getHours()
	var min = date.getMinutes()
	if(min <10) min = "0" + min;
	var s = date.getSeconds();
	if(s <10) s = "0" + s;
	var time = y + "-" + m + "-" + d + "  " + h + " : " + min + " : " + s
	document.getElementById('time').innerHTML = time;
}

var t =null;
window.onload = function (){
	showTime()
	setInterval(showTime,1000);
	//每三秒换一次图
	t = window.setInterval(showImg,3000);
	//鼠标点击事件,点击数字 显示对应图片
	//获取所有数字li
	var numLis = document.getElementById("nums").getElementsByTagName('li');
	//给每个li绑定单击事件
	for (var i = 0; i < numLis.length; i++){
		numLis[i].onclick = function(){
			
			window.clearInterval(t);//定时器不要的一定要清除
			t = null;
			index = parseInt(this.innerHTML) - 1;
			showImg();
			
			t = window.setInterval(showImg,3000);
		}
	}
	
}

var index = 0;/**默认显示第一个li/
/*图片显示方法*/
function showImg(){
	var imgLis =document.getElementById("imgs").getElementsByTagName('li');
	var numLis =document.getElementById("nums").getElementsByTagName('li');
	/*循环imglis数组 当前循环对象索引值和index相等 显示该li否则隐藏*/
	for(var i = 0; i < imgLis.length; i++){
		if(i == index){
			imgLis[i].style.display = "block";
			numLis[i].style.backgroundColor = "red"
		}else{
			imgLis[i].style.display = "none";
			numLis[i].style.backgroundColor = "seagreen"
		}
		}
		index++;
		if(index >= imgLis.length){
			index=0;
	}
}

/*编写发送异步请求获取服务器服务端数据*/
$(function($){
	console.log('阿啦啦 页面加载完毕');
	var server_url = "http://127.0.0.1:8080"
	$.getJSON(server_url+"/AdimgServelt",{},function(data){
		console.log(data);//后台返回的数据
		var content = ''
		if(data.length >1){
		for(var i = 0; i < data.length;i++){
			console.log(server_url+data[i].img_url)
			content = content + '<li><a href="'+ data[i].img_page+'"><img src="' +server_url + data[i].img_url+'" title="'+data[i].img_desc+'"></a></li>';
		}
		
		document.getElementById('imgs').innerHTML=content;
		}
	})
})





function showTab(showId,hiddId){
	document.getElementById(showId).style.display = "block";
	document.getElementById(hiddId).style.display = "none";
	document.getElementById("center-right_bottom_nav").className = showId;
}

/*
<ul id="imgs">
						<li><a href=""><img src="img/ad-01.jpg" alt=""></a></li>
						<li><a href=""><img src="img/ad-02.jpg" alt=""></a></li>
						<li><a href=""><img src="img/ad-03.jpg" alt=""></a></li>
						<li><a href=""><img src="img/ad-04.jpg" alt=""></a></li>
					</ul>
*/


/*隐藏广告*/
function hiddenAd(id){
	document.getElementById(id).style.display = 'none'
}

$(function($){
	console.log('done!');
	var web_name=new Array("网易","百度","GOOGLE","京东","淘宝","网易","百度","GOOGLE","京东","淘宝")
	
	var server_url = "http://127.0.0.1:8080"
	$.getJSON(server_url+"/DizhiServlet",{},function(data){
		console.log(data);//后台返回json数据
		if(data.length > 1){
			var content = '';  
			for(var i = 0 ; i < data.length; i++){
					console.log(data[i].url)
					content = content + '<li><a href="'+data[i].url+'">|&nbsp&nbsp'+web_name[i]+'&nbsp&nbsp</a></li>';
		
			}
				//将替换内容放入id为links的节点里
			document.getElementById('links').innerHTML = content;
			
		}
		document.getElementById('links').style.marginLeft='25%';
		
	})
})